import java.io.BufferedReader;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.util.HashMap;

public class ContadorDeOcorrencia {
	private static HashMap<String, Integer> ocorrencias = new HashMap<String, Integer>();
	private static BufferedReader entrada;
	private static FileOutputStream saida;
	
	public static void main(String[] args) {
        try {
        	entrada = new BufferedReader(new FileReader(args[0]));
        	saida = new FileOutputStream(args[1]);
        	contaOcorrencias();
        	gravaOcorrencias();
            entrada.close();
            saida.close();
        } catch(Exception ex) {
            System.err.print(ex.getMessage());
        }
	}
	
    private static void contaOcorrencias() throws Exception {
	    String string;
	    while ((string = entrada.readLine()) != null) {
    		if (ocorrencias.containsKey(string.toLowerCase())) {
    			ocorrencias.put(string.toLowerCase(), ocorrencias.get(string.toLowerCase())+1);
    		} else {
    			ocorrencias.put(string.toLowerCase(), 1);
    		}
	    }
    }
    
    private static void gravaOcorrencias() throws Exception {
        for (String palavra: ocorrencias.keySet()) {
        	saida.write((palavra + " - " + ocorrencias.get(palavra) + System.getProperty("line.separator")).getBytes());
        }
    }
}